<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>달력(출처:블루비, 하지만 고칠부분이 많아 뜯어고쳤음)</title>
</head>
<body>
<center>
<script language="JavaScript">
var timerID = null;
var timerRunning = false;
var id,pause=0,position=0;
function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11)
{
   this[0] = m0;
   this[1] = m1;
   this[2] = m2;
   this[3] = m3;
   this[4] = m4;
   this[5] = m5;
   this[6] = m6;
   this[7] = m7;
   this[8] = m8;
   this[9] = m9;
   this[10] = m10;
   this[11] = m11;
}
function calendar()
{
   var monthNames = "1월2월3월4월5월6월7월8월9월10월11월12월";	// 월, 한글로 수정
   var today = new Date();
   var thisDay;
   var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30,
      31, 30, 31);
   year = today.getYear()+1900;	// +1900 추가
   thisDay = today.getDate();
   if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
      monthDays[1] = 29;	// 2월에 대한 if문
   nDays = monthDays[today.getMonth()];
   firstDay = today;
   firstDay.setDate(1); // works fine for most systems
   testMe = firstDay.getDate();
   if (testMe == 2)
        firstDay.setDate(0);
   startDay = firstDay.getDay();
   document.write("<TABLE BORDER='0'>");
   document.write("<TR><td COLSPAN=7 align=center><b>");
   document.write("20"+year%100+"년 ");	// 년월 순서 변경, 익스플로러와 파폭간의 차이로 나머지 계산으로 수정
   if(today.getMonth()<9){	// 9월 이하
	   document.write(monthNames.substring(today.getMonth() * 2,
			   (today.getMonth() + 1) * 2));
   }else if(today.getMonth()>10){	// 12월
	   document.write(monthNames.substring(today.getMonth() * 2 + 2));
   }else if(today.getMonth()>9){	// 11월
	   document.write(monthNames.substring(today.getMonth() * 2 + 1,
			   (today.getMonth() + 2) * 2));
   }else{	// 10월
	   document.write(monthNames.substring(today.getMonth() * 2,
			   (today.getMonth() + 1) * 2 + 1));
   }	// 10월 이후로 substring 자르는 범위 추가 수정완료!
   document.write("</TR></td>");
   document.write("<TR><td><b>일</b></td><td><b>월</b></td><td><b>화</b></td>"
		   +"<td><b>수</b></td><td><b>목</b></td><td><b>금</b></td><td><b>토</b></td></tr>");
   document.write("<TR>");
   column = 0;
   for (i=0; i<startDay; i++)
   {
      document.write("<TD>&nbsp;</td>");
      column++;
   }
   for (i=1; i<=nDays; i++)
   {
      document.write("<TD>");
      if (i == thisDay)
         document.write("<FONT COLOR=\"#FF0000\">")
      document.write(i);
      if (i == thisDay)
        document.write("</FONT>")
      column++;
      if (column == 7)
      {
         document.write("</tr><TR>"); 
         column = 0;
      }
      document.write("</TD>");
   }
   document.write("</tr></TABLE>");
   document.writeln("</CENTER>");
}
document.write("</br>");
calendar();
document.write("");
</SCRIPT>
</center>
</body>
</html>